﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Royaumes_Libres.Database;

namespace Royaumes_Libres
{
    public partial class userpop : System.Web.UI.Page
    {
        cUsers pUser;
        cKingdom pKingdom;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[Properties.Settings.Default.ObjUser] != null)
            {
                pUser = (cUsers)Session[Properties.Settings.Default.ObjUser];
                pKingdom = new cKingdom(pUser.PkUser, pUser.ActiveWorld);
                FillSlider();
            }
        }

        protected void FillSlider()
        {
                cWorks pWorks;
                pWorks = cWorks.GetWorks(pKingdom.PkKingdom);

                this.Farmer.InnerHtml = pWorks.Farmer.ToString();
                this.Miner.InnerHtml = pWorks.Miner.ToString();
                this.Disciple.InnerHtml = pWorks.Disciple.ToString();
                this.Worker.InnerHtml = pWorks.Worker.ToString();
                this.Lumberjack.InnerHtml = pWorks.Lumberjack.ToString();
                this.txtFarmer.Value = pWorks.Farmer.ToString();
                this.txtMiner.Value = pWorks.Miner.ToString();
                this.txtDisciple.Value = pWorks.Disciple.ToString();
                this.txtWorker.Value = pWorks.Worker.ToString();
                this.txtLumberjack.Value = pWorks.Lumberjack.ToString();

                this.myFkKingdom.Value = pKingdom.PkKingdom.ToString();

                this.txtReste.Value = (100 - pWorks.Farmer - pWorks.Miner - pWorks.Disciple - pWorks.Worker - pWorks.Lumberjack).ToString();

                this.tblLabelPop.Rows[0].Cells[0].Text = cText.GetText("Farmer");
                this.tblLabelPop.Rows[0].Cells[1].Text = cText.GetText("Miner");
                this.tblLabelPop.Rows[0].Cells[2].Text = cText.GetText("Disciple");
                this.tblLabelPop.Rows[0].Cells[3].Text = cText.GetText("Worker");
                this.tblLabelPop.Rows[0].Cells[4].Text = cText.GetText("Lumberjack");
        }
    }
}